<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/19
 * Time: 16:26
 */

namespace App\Service;

use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;



class TestService
{

    function yiburenwu($data){

        sleep(10);
        print_r($data);
        echo '123123';
    }

    function A($fd){
        $fds=Redis::get('fds');
        if(empty($fds)){
            $fds=[];
            $fds[]=$fd;
        }else{
            $fds[]=$fd;
        }
        Redis::set('fds',$fds);
    }
    function B($fd,$msg){
        $fds=Redis::get('fds');
        if(!empty($fds)){
            foreach ($fds as $key=>$fd){
                $msgs= Redis::get($fd);

            }
        }
    }
    function C(){
        sleep(20);
        Log::info('记录事件C');
    }
    //推送消息
    function Push($data){
        $server=$data['service'];
        $fds=Redis::get('fds');
        $fds=json_decode($fds,true);
        if(!empty($fds)){
            foreach ($fds as $key=>$fd){
                if ($fd!=$data['fd']){
                    $server->push($fd,$data['info']);
                }
            }
        }
    }


}